<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" oninput="change(this)">
    <h1 id="show"></h1>
    <script>
        var obj = {
                text: ""
            }
            // proxy代理相比Object.defineProperty可以深度监听数组和对象的变化
        var p = new Proxy(obj, {
            get() {},
            set(target, key, val) {
                target[key] = val;
                document.getElementById("show").innerHTML = val;
            }
        })

        function change(that) {
            console.log(that.value)
            p.text = that.value;
        }
    </script>
</body>

</html>